@extends('layouts.app')
@include('good.sidebar')
@section('content')
    <div class="content" style="overflow:auto">
        <div class="row custom-invoice"   style="min-width: 800px">
            <form class="form" method="post" action="{{ route('admin.good.spec.update', ['id' => $good->id, 'redirect' => $redirect]) }}">
                <input type="hidden" value="{{ csrf_token() }}" name="_token">
                <table class="table" >
                    <thead>
                    <tr>
                        @foreach($attr as $item)
                            <th>{{ $item->name }}</th>
                        @endforeach
                            <th>库存</th>
{{--                            <th>划线价</th>--}}
                            <th>价格</th>
                            <th>预付价格</th>
                            <th>返利会员奖励金额</th>
                            <th>城市合伙人奖励金额</th>
                            <th>非本集团或商家职员奖励金额</th>
                            <th>本集团或商家职员奖励金额</th>
                            <th>合伙人推荐单员工奖励金额</th>
                    </tr>
                    </thead>
                    <tbody>
                    @foreach($data as $value)
                        <?php $k = []; ?>
                        <tr>
                            @foreach($value as $key => $value2)
                                <?php
                                    $k[] = $key;
                                ?>
                                <td>{{ $value2 }}</td>
                            @endforeach
                                <?php
                                    $name = implode(",", $k);
                                    $tmp = $spec->get($name);

                                    $price = is_null($tmp)? null : $tmp->price/100;
//                                    $displayPrice = is_null($tmp)? null : $tmp->display_price/100;
                                    $prepayPrice = is_null($tmp)? null: $tmp->prepay_price/100;
                                    $stock = is_null($tmp)? 10000:$tmp->stock;
                                    $level1Rebate = is_null($tmp)? 0 : $tmp->level1_rebate/100;
                                    $level2Rebate = is_null($tmp)? 0 : $tmp->level2_rebate/100;
                                    $level3Rebate = is_null($tmp)? 0 : $tmp->level3_rebate/100;
                                    $level4Rebate = is_null($tmp)? 0 : $tmp->level4_rebate/100;
                                    $level23Rebate = is_null($tmp)? 0 : $tmp->level_2_3_rebate/100;
                                ?>
                                <td>
                                    {!! Form::input('text', "stock[{$name}]", $stock, ['class' => 'form-control']); !!}
                                </td>
{{--                                <td>--}}
{{--                                    {!! Form::input('text', "display_price[{$name}]", $displayPrice, ['class' => 'form-control', 'required' => 'required']); !!}--}}
{{--                                </td>--}}
                                <td>
                                    {!! Form::input('text', "price[{$name}]", $price, ['class' => 'form-control', 'required' => 'required']) !!}
                                </td>
                                <td>
                                    {!! Form::input('text', "prepay_price[{$name}]", $prepayPrice, ['class' => 'form-control']) !!}
                                </td>
                                <td>
                                    {!! Form::input('text', "level1_rebate[{$name}]", $level1Rebate, ['class' => 'form-control', 'required' => 'required']) !!}
                                </td>
                                <td>
                                    {!! Form::input('text', "level2_rebate[{$name}]", $level2Rebate, ['class' => 'form-control', 'required' => 'required']) !!}
                                </td>
                                <td>
                                    {!! Form::input('text', "level4_rebate[{$name}]", $level4Rebate, ['class' => 'form-control', 'required' => 'required']) !!}
                                </td>
                                <td>
                                    {!! Form::input('text', "level3_rebate[{$name}]", $level3Rebate, ['class' => 'form-control', 'required' => 'required']) !!}
                                </td>
                                <td>
                                    {!! Form::input('text', "level_2_3_rebate[{$name}]", $level23Rebate, ['class' => 'form-control', 'required' => 'required']) !!}
                                </td>
                        </tr>
                    @endforeach
                    </tbody>
                </table>
                <input type="submit" class="form-control btn btn-success" value="保存">
            </form>
        </div>
    </div>
@endsection
